home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 December / 2004-12 CHIP.iso / Narzedzia systemowe / Inno Setup 5.0.4 Beta / isetup-5.0.4-beta.exe / {app} / Examples / CodeClasses.iss < prev    next >
Text File  |  2004-08-02  |  11KB  |  315 lines

  1. ; -- CodeClasses.iss --
  2. ;
  3. ; This script shows how to use the WizardForm object and the various VCL classes.
  4.  
  5. [Setup]
  6. AppName=My Program
  7. AppVerName=My Program version 1.5
  8. CreateAppDir=no
  9. DisableProgramGroupPage=yes
  10. DefaultGroupName=My Program
  11. UninstallDisplayIcon={app}\MyProg.exe
  12. WindowVisible=yes
  13.  
  14. [Files]
  15. Source: compiler:WizModernSmallImage.bmp; Flags: dontcopy
  16.  
  17. [Code]
  18. procedure ButtonOnClick(Sender: TObject);
  19. begin
  20.   MsgBox('You clicked the button!', mbInformation, mb_Ok);
  21. end;
  22.  
  23. procedure FormButtonOnClick(Sender: TObject);
  24. var
  25.   Form: TSetupForm;
  26.   OKButton, CancelButton: TButton;
  27. begin
  28.   Form := CreateCustomForm();
  29.   try
  30.     Form.ClientWidth := ScaleX(256);
  31.     Form.ClientHeight := ScaleY(256);
  32.     Form.Caption := 'TSetupForm';
  33.     Form.CenterInsideControl(WizardForm, False);
  34.  
  35.     OKButton := TButton.Create(Form);
  36.     OKButton.Parent := Form;
  37.     OKButton.Width := ScaleX(75);
  38.     OKButton.Height := ScaleY(23);
  39.     OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
  40.     OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  41.     OKButton.Caption := 'OK';
  42.     OKButton.ModalResult := mrOk;
  43.  
  44.     CancelButton := TButton.Create(Form);
  45.     CancelButton.Parent := Form;
  46.     CancelButton.Width := ScaleX(75);
  47.     CancelButton.Height := ScaleY(23);
  48.     CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
  49.     CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
  50.     CancelButton.Caption := 'Cancel';
  51.     CancelButton.ModalResult := mrCancel;
  52.     CancelButton.Cancel := True;
  53.  
  54.     Form.ActiveControl := OKButton;
  55.  
  56.     if Form.ShowModal() = mrOk then
  57.       MsgBox('You clicked OK.', mbInformation, MB_OK);
  58.   finally
  59.     Form.Free();
  60.   end;
  61. end;
  62.  
  63. procedure CreateTheWizardPages;
  64. var
  65.   Page: TWizardPage;
  66.   Button, FormButton: TButton;
  67.   CheckBox: TCheckBox;
  68.   Edit: TEdit;
  69.   PasswordEdit: TPasswordEdit;
  70.   Memo: TMemo;
  71.   Lbl, ProgressBarLabel: TLabel;
  72.   ComboBox: TComboBox;
  73.   ListBox: TListBox;
  74.   StaticText: TNewStaticText;
  75.   ProgressBar: TNewProgressBar;
  76.   CheckListBox, CheckListBox2: TNewCheckListBox;
  77.   FolderTreeView: TFolderTreeView;
  78.   BitmapImage, BitmapImage2, BitmapImage3: TBitmapImage;
  79.   BitmapFileName: String;
  80.   RichEditViewer: TRichEditViewer;
  81. begin
  82.   { TButton and others }
  83.  
  84.   Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
  85.  
  86.   Button := TButton.Create(Page);
  87.   Button.Width := ScaleX(75);
  88.   Button.Height := ScaleY(23);
  89.   Button.Caption := 'TButton';
  90.   Button.OnClick := @ButtonOnClick;
  91.   Button.Parent := Page.Surface;
  92.  
  93.   CheckBox := TCheckBox.Create(Page);
  94.   CheckBox.Top := Button.Top + Button.Height + ScaleY(8);
  95.   CheckBox.Width := Page.SurfaceWidth;
  96.   CheckBox.Height := ScaleY(17);
  97.   CheckBox.Caption := 'TCheckBox';
  98.   CheckBox.Checked := True;
  99.   CheckBox.Parent := Page.Surface;
  100.  
  101.   Edit := TEdit.Create(Page);
  102.   Edit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  103.   Edit.Width := Page.SurfaceWidth div 2 - ScaleX(8);
  104.   Edit.Text := 'TEdit';
  105.   Edit.Parent := Page.Surface;
  106.  
  107.   PasswordEdit := TPasswordEdit.Create(Page);
  108.   PasswordEdit.Left := Page.SurfaceWidth - Edit.Width;
  109.   PasswordEdit.Top := CheckBox.Top + CheckBox.Height + ScaleY(8);
  110.   PasswordEdit.Width := Edit.Width;
  111.   PasswordEdit.Text := 'TPasswordEdit';
  112.   PasswordEdit.Parent := Page.Surface;
  113.  
  114.   Memo := TMemo.Create(Page);
  115.   Memo.Top := Edit.Top + Edit.Height + ScaleY(8);
  116.   Memo.Width := Page.SurfaceWidth;
  117.   Memo.Height := ScaleY(89);
  118.   Memo.ScrollBars := ssVertical;
  119.   Memo.Text := 'TMemo';
  120.   Memo.Parent := Page.Surface;
  121.  
  122.   Lbl := TLabel.Create(Page);
  123.   Lbl.Top := Memo.Top + Memo.Height + ScaleY(8);
  124.   Lbl.Caption := 'TLabel';
  125.   Lbl.AutoSize := True;
  126.   Lbl.Parent := Page.Surface;
  127.  
  128.   FormButton := TButton.Create(Page);
  129.   FormButton.Top := Lbl.Top + Lbl.Height + ScaleY(8);
  130.   FormButton.Width := ScaleX(75);
  131.   FormButton.Height := ScaleY(23);
  132.   FormButton.Caption := 'TSetupForm';
  133.   FormButton.OnClick := @FormButtonOnClick;
  134.   FormButton.Parent := Page.Surface;
  135.  
  136.   { TComboBox and others }
  137.  
  138.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TComboBox');
  139.  
  140.   ComboBox := TComboBox.Create(Page);
  141.   ComboBox.Width := Page.SurfaceWidth;
  142.   ComboBox.Parent := Page.Surface;
  143.   ComboBox.Items.Add('TComboBox');
  144.   ComboBox.ItemIndex := 0;
  145.  
  146.   ListBox := TListBox.Create(Page);
  147.   ListBox.Top := ComboBox.Top + ComboBox.Height + ScaleY(8);
  148.   ListBox.Width := Page.SurfaceWidth;
  149.   ListBox.Height := ScaleY(97);
  150.   ListBox.Parent := Page.Surface;
  151.   ListBox.Items.Add('TListBox');
  152.   ListBox.ItemIndex := 0;
  153.  
  154.   StaticText := TNewStaticText.Create(Page);
  155.   StaticText.Top := ListBox.Top + ListBox.Height + ScaleY(8);
  156.   StaticText.Caption := 'TNewStaticText';
  157.   StaticText.AutoSize := True;
  158.   StaticText.Parent := Page.Surface;
  159.  
  160.   ProgressBarLabel := TLabel.Create(Page);
  161.   ProgressBarLabel.Top := StaticText.Top + StaticText.Height + ScaleY(8);
  162.   ProgressBarLabel.Caption := 'TNewProgressBar';
  163.   ProgressBarLabel.AutoSize := True;
  164.   ProgressBarLabel.Parent := Page.Surface;
  165.  
  166.   ProgressBar := TNewProgressBar.Create(Page);
  167.   ProgressBar.Left := ProgressBarLabel.Width + ScaleX(8);
  168.   ProgressBar.Top := ProgressBarLabel.Top;
  169.   ProgressBar.Width := Page.SurfaceWidth - ProgressBar.Left;
  170.   ProgressBar.Height := ProgressBarLabel.Height + ScaleY(8);
  171.   ProgressBar.Parent := Page.Surface;
  172.   ProgressBar.Position := 25;
  173.  
  174.   { TNewCheckListBox }
  175.  
  176.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TNewCheckListBox');
  177.  
  178.   CheckListBox := TNewCheckListBox.Create(Page);
  179.   CheckListBox.Width := Page.SurfaceWidth;
  180.   CheckListBox.Height := ScaleY(97);
  181.   CheckListBox.Flat := True;
  182.   CheckListBox.Parent := Page.Surface;
  183.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  184.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, True, True, nil);
  185.   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
  186.   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
  187.  
  188.   CheckListBox2 := TNewCheckListBox.Create(Page);
  189.   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);
  190.   CheckListBox2.Width := Page.SurfaceWidth;
  191.   CheckListBox2.Height := ScaleY(97);
  192.   CheckListBox2.BorderStyle := bsNone;
  193.   CheckListBox2.ParentColor := True;
  194.   CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
  195.   CheckListBox2.ShowLines := False;
  196.   CheckListBox2.WantTabs := True;
  197.   CheckListBox2.Parent := Page.Surface;
  198.   CheckListBox2.AddGroup('TNewCheckListBox', '', 0, nil);
  199.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, True, True, nil);
  200.   CheckListBox2.AddRadioButton('TNewCheckListBox', '', 0, False, True, nil);
  201.  
  202.   { TFolderTreeView }
  203.  
  204.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TFolderTreeView');
  205.  
  206.   FolderTreeView := TFolderTreeView.Create(Page);
  207.   FolderTreeView.Width := Page.SurfaceWidth;
  208.   FolderTreeView.Height := Page.SurfaceHeight;
  209.   FolderTreeView.Parent := Page.Surface;
  210.   FolderTreeView.Directory := ExpandConstant('{src}');
  211.  
  212.   { TBitmapImage }
  213.  
  214.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TBitmapImage');
  215.  
  216.   BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
  217.   ExtractTemporaryFile(ExtractFileName(BitmapFileName));
  218.  
  219.   BitmapImage := TBitmapImage.Create(Page);
  220.   BitmapImage.AutoSize := True;
  221.   BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
  222.   BitmapImage.Parent := Page.Surface;
  223.  
  224.   BitmapImage2 := TBitmapImage.Create(Page);
  225.   BitmapImage2.BackColor := $400000;
  226.   BitmapImage2.Bitmap := BitmapImage.Bitmap;
  227.   BitmapImage2.Center := True;
  228.   BitmapImage2.Left := BitmapImage.Width + 10;
  229.   BitmapImage2.Height := 2*BitmapImage.Height;
  230.   BitmapImage2.Width := 2*BitmapImage.Width;
  231.   BitmapImage2.Parent := Page.Surface;
  232.  
  233.   BitmapImage3 := TBitmapImage.Create(Page);
  234.   BitmapImage3.Bitmap := BitmapImage.Bitmap;
  235.   BitmapImage3.Stretch := True;
  236.   BitmapImage3.Left := 3*BitmapImage.Width + 20;
  237.   BitmapImage3.Height := 4*BitmapImage.Height;
  238.   BitmapImage3.Width := 4*BitmapImage.Width;
  239.   BitmapImage3.Parent := Page.Surface;
  240.  
  241.   { TRichViewer }
  242.  
  243.   Page := CreateCustomPage(Page.ID, 'Custom wizard page controls', 'TRichViewer');
  244.  
  245.   RichEditViewer := TRichEditViewer.Create(Page);
  246.   RichEditViewer.Width := Page.SurfaceWidth;
  247.   RichEditViewer.Height := Page.SurfaceHeight;
  248.   RichEditViewer.Parent := Page.Surface;
  249.   RichEditViewer.ScrollBars := ssVertical;
  250.   RichEditViewer.UseRichEdit := True;
  251.   RichEditViewer.RTFText := '{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue128;}\viewkind4\uc1\pard\f0\fs20 T\cf1 Rich\cf2 Edit\cf3 Viewer\cf0\par}';
  252.   RichEditViewer.ReadOnly := True;
  253. end;
  254.  
  255. procedure AboutButtonOnClick(Sender: TObject);
  256. begin
  257.   MsgBox('This demo shows some features of the WizardForm object and the various VCL classes.', mbInformation, mb_Ok);
  258. end;
  259.  
  260. procedure URLLabelOnClick(Sender: TObject);
  261. var
  262.   ErrorCode: Integer;
  263. begin
  264.   ShellExec('open', 'http://www.innosetup.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
  265. end;
  266.  
  267. procedure InitializeWizard();
  268. var
  269.   AboutButton, CancelButton: TButton;
  270.   URLLabel: TNewStaticText;
  271.   BackgroundBitmapImage: TBitmapImage;
  272.   BackgroundBitmapText: TNewStaticText;
  273. begin
  274.   { Custom wizard pages }
  275.  
  276.   CreateTheWizardPages;
  277.   
  278.   { Other custom controls }
  279.  
  280.   CancelButton := WizardForm.CancelButton;
  281.  
  282.   AboutButton := TButton.Create(WizardForm);
  283.   AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
  284.   AboutButton.Top := CancelButton.Top;
  285.   AboutButton.Width := CancelButton.Width;
  286.   AboutButton.Height := CancelButton.Height;
  287.   AboutButton.Caption := '&About...';
  288.   AboutButton.OnClick := @AboutButtonOnClick;
  289.   AboutButton.Parent := WizardForm;
  290.   
  291.   URLLabel := TNewStaticText.Create(WizardForm);
  292.   URLLabel.Caption := 'www.innosetup.com';
  293.   URLLabel.Cursor := crHand;
  294.   URLLabel.OnClick := @URLLabelOnClick;
  295.   URLLabel.Parent := WizardForm;
  296.   { Alter Font *after* setting Parent so the correct defaults are inherited first }
  297.   URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
  298.   URLLabel.Font.Color := clBlue;
  299.   URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
  300.   URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
  301.  
  302.   BackgroundBitmapImage := TBitmapImage.Create(MainForm);
  303.   BackgroundBitmapImage.Left := 50;
  304.   BackgroundBitmapImage.Top := 100;
  305.   BackgroundBitmapImage.AutoSize := True;
  306.   BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
  307.   BackgroundBitmapImage.Parent := MainForm;
  308.   
  309.   BackgroundBitmapText := TNewStaticText.Create(MainForm);
  310.   BackgroundBitmapText.Left := BackgroundBitmapImage.Left;
  311.   BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height + ScaleY(8);
  312.   BackgroundBitmapText.Caption := 'TBitmapImage';
  313.   BackgroundBitmapText.Parent := MainForm;
  314. end;
  315.